public class Dog {
    public String name;
    public int age;
    public String color;



    //构造方法 在实例化对象的时候被调用
    public Dog() {
        this("大黄",3,"black");//这行代码表示，调用该类中其他构造方法，带有三个参数的
        System.out.println("不带参数的构造方法！");
//        this.name="大黄";
//        this.age=3;
//        this.color="black";
    }

    public Dog(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
        System.out.println("调用这个构造方法");
    }

    public void eat() {
        System.out.println(this.name+"正在吃狗粮！");
    }

    public void sleep() {
        System.out.println(this.name+"正在睡觉");
    }

    public void show() {
        System.out.println("姓名:"+this.name+",年龄:"+this.age+",颜色:"+this.color);
    }

    public static void main(String[] args) {
        Dog dog=new Dog();
        dog.show();

//        Dog dog1=new Dog("花花",4,"black and white");
//        dog1.show();
//
//        Dog dog2=new Dog("汤圆",5," white");
//        dog2.show();
    }

    public static void main1(String[] args) {
        Dog dog=new Dog();
        dog.name="小黄";
        dog.age=2;
        dog.color="yellow";
        dog.eat();
        dog.sleep();
        dog.show();
    }
}
